﻿#region Copyright(C) 2018 FI Ltd. All rights reserved.
// ==================================================================================================
// Copyright(C) 2018 FI Ltd. All rights reserved.
//
// SYSTEM NAME	    : FI.Net Application Framework
// COMPONENT ID	    : FI.Core
// COMPONENT DESC   : FI.Net Core Foundation
//
// CREATED DATE/BY  : 18 Aug 2018 / Tian Mi
//
// REVISION HISTORY :	
// DATE/BY			SR#/CS/PM#/OTHERS		DESCRIPTION OF CHANGE
// ==================================================================================================
#endregion

namespace FI.Core.Caching
{
    /// <summary>
    /// A fake cache store which will never perform any caching operation.
    /// </summary>
    public class FakeCacheStore: ICacheStore
    {
        /// <summary>
        /// Gets a value indicating whether this <see cref="ICacheStore" /> is enabled.
        /// </summary>
        /// <value>
        ///   <c>true</c> if enabled; otherwise, <c>false</c>.
        /// </value>
        public bool Enabled
        {
            get { return false; }
        }

        /// <summary>
        /// Adds the specified value into cache.
        /// </summary>
        /// <param name="key">The key of the cache item to be added.</param>
        /// <param name="value">The value of the cache item to be added.</param>
        public void Add(string key, object value) {}

        /// <summary>
        /// Tries the get value of the cache item based on the given key.
        /// </summary>
        /// <param name="key">The key of the cache item.</param>
        /// <param name="value">The value of the cache item.</param>
        /// <returns>
        /// A <see cref="bool" /> value indicating whether to get the value from cache store.
        /// </returns>
        public bool TryGetData(string key, out object value)
        {
            return (value = null) != null;
        }

        /// <summary>
        /// Tries the get value of the cache item based on the given key.
        /// </summary>
        /// <typeparam name="T">The type of the cache item's value.</typeparam>
        /// <param name="key">The key of the cache item.</param>
        /// <param name="value">The value of the cache item.</param>
        /// <returns>
        /// A <see cref="bool" /> value indicating whether to get the value from cache store.
        /// </returns>
        public bool TryGetData<T>(string key, out T value)
        {
            value = default(T);
            return false;
        }

        /// <summary>
        /// Remove all cache items added by the cache store itself.
        /// </summary>
        public void Clear() { }

        /// <summary>
        /// Adds or replaces an object in the cache.
        /// </summary>
        /// <param name="key">The unique value that is used to identify the object in the cache.</param>
        /// <param name="value">The object to add or replace.</param>
        public void Put(string key, object value)
        {

        }

        /// <summary>
        /// Remove specified cahce item.
        /// </summary>
        /// <param name="key">The key of cache item to be deleted.</param>
        public void Remove(string key)
        {

        }
    }
}
